Skip to content

Shared, Unified: Add shared CFG fallthrough handling and support Swift's fallthrough - #23157

Merged
paldepind merged 8 commits into
mainfrom
unified/swift-fallthroug
Nov 18, 2026
Merged

paldepind merged 8 commits into
mainfrom
unified/swift-fallthroug

Conversation

@paldepind

@paldepind paldepind commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor
  • Implement support for fallthrough statements in the shared CFG library.
  • Extract Swift's fallthrough statements and instantiate the shared CFG library with them.
  • Change Go's instantiation of the shared CFG library to use fallthrough statements. Go had a "manual" implementation before. That approach didn't scale to Swift where fallthrough statements can appear anywhere within a case block. The other way around works though.

@paldepind paldepind changed the title Unified: Support Swift fallthrough and shared CFG fallthrough handling Shared, Unified: Add shared CFG fallthrough handling and support Swift's fallthrough Nov 17, 2026
@paldepind
paldepind marked this pull request as ready for review November 17, 2026 14:12
@paldepind
paldepind requested review from a team as code owners November 17, 2026 14:12
Copilot AI adaptive review requested due to automatic review settings November 17, 2026 14:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The PR description lacks final-revision DCA results with changed-results and regression analysis, and Swift retains an obsolete, unreachable fallThroughStmt mapping.

2 open issues
What changed in this PR

Adds explicit fallthrough support to the shared control-flow graph (CFG), enabling Swift analysis and replacing Go’s language-specific handling.

Changes:

  • Add shared fallthrough successor edges and update language adapters.
  • Extract and model Swift fallthrough statements; migrate Go to the shared implementation.
  • Add Swift nesting/defer tests and Go empty-case tests, with updated expected outputs.
File Description
unified/​ql/​test/​library-tests/​controlflow/​fallthrough.swift Test chained, nested, conditional, and deferred fallthrough.
unified/​ql/​test/​library-tests/​controlflow/​cfg.swift Update existing fallthrough expectations.
unified/​ql/​test/​library-tests/​controlflow/​cfg.expected Update expected Swift CFG results.
unified/​ql/​test/​library-tests/​controlflow/​basicblock-slices.expected Update expected basic-block slices.
unified/​ql/​lib/​unified.dbscheme Add the fallthrough statement token.
unified/​ql/​lib/​codeql/​unified/​internal/​ControlFlowGraph.qll Connect unified fallthrough statements to the shared CFG.
unified/​ql/​lib/​codeql/​unified/​internal/​Ast.qll Expose the unified fallthrough AST class.
unified/​extractor/​tests/​corpus/​swift/​control-flow/​fallthrough.output Update expected extraction output.
unified/​extractor/​src/​languages/​swift/​swift.rs Translate Swift fallthrough statements.
unified/​extractor/​ast_types.yml Define fallthrough in the unified AST schema.
shared/​controlflow/​codeql/​controlflow/​SuccessorType.qll Introduce the fallthrough successor type.
shared/​controlflow/​codeql/​controlflow/​ControlFlowGraph.qll Route abrupt fallthrough to the next case body.
ruby/​ql/​lib/​codeql/​ruby/​controlflow/​ControlFlowGraph.qll Supply an empty fallthrough class for Ruby.
python/​ql/​lib/​semmle/​python/​controlflow/​internal/​AstNodeImpl.qll Supply an empty fallthrough class for Python.
java/​ql/​lib/​semmle/​code/​java/​ControlFlowGraph.qll Supply an empty fallthrough class for Java.
go/​ql/​test/​library-tests/​semmle/​go/​controlflow/​ControlFlowGraph/​fallthrough.go Test fallthrough into empty cases and defaults.
go/​ql/​test/​library-tests/​semmle/​go/​controlflow/​ControlFlowGraph/​ControlFlowNode_getASuccessor.expected Update expected Go successor edges.
go/​ql/​lib/​semmle/​go/​controlflow/​ControlFlowGraphImpl.qll Replace manual fallthrough handling with shared support.
csharp/​ql/​lib/​semmle/​code/​csharp/​controlflow/​internal/​ControlFlowGraph.qll Supply an empty fallthrough class for C#.
actions/​ql/​lib/​codeql/​actions/​controlflow/​internal/​Cfg.qll Supply an empty fallthrough class for Actions.

Review effort: Max (adaptive)

@paldepind paldepind added the no-change-note-required This PR does not need a change note label Nov 17, 2026
paldepind and others added 8 commits November 18, 2026 08:46
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 23fe5d28-31ea-484f-aa0e-82adaedaf057
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 23fe5d28-31ea-484f-aa0e-82adaedaf057
Add a `fallthrough` statement node, map Swift syntax to it, and
regenerate the AST library, database schema, and extractor corpus
output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 23fe5d28-31ea-484f-aa0e-82adaedaf057
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 23fe5d28-31ea-484f-aa0e-82adaedaf057
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 23fe5d28-31ea-484f-aa0e-82adaedaf057
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 23fe5d28-31ea-484f-aa0e-82adaedaf057
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 23fe5d28-31ea-484f-aa0e-82adaedaf057
@paldepind
paldepind force-pushed the unified/swift-fallthroug branch from d19710b to f79c3fe Compare November 18, 2026 07:46

@aschackmull aschackmull left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@paldepind
paldepind merged commit 9a66ef1 into main Nov 18, 2026
123 of 124 checks passed
@paldepind
paldepind deleted the unified/swift-fallthroug branch November 18, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Actions Analysis of GitHub Actions C# Go Java no-change-note-required This PR does not need a change note Python Ruby Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants